<?php
namespace app\admin\controller;
use \app\admin\controller\Auth;
/**
 * 需要登录的抽象基类 指定一个操作的站点
 */
abstract class AuthSite extends Auth{
    
    
    private $siteObject; // 当前用户登录的站点对象
    protected $siteId;   // 当前管理站点ID
        
    public function __construct(){
        parent::__construct();       
        $siteId = session('c_login_siteid');  
        if( !$siteId ) $this->redirect('/index/index');
        $this->siteId = $siteId;
        $this->getUser()->setSiteId($siteId);
    }
    
    
    /**
     * 读取当前站点对象
     */
    protected function getSite($siteId = false){
        if( !$this->siteObject ){
            if( !$siteId ) $siteId = $this->siteId;
            $this->siteObject = new \logic\site\Site($siteId);
        }
        return $this->siteObject;        
    }
}